Skip to content

Conversation

@ondrejmirtes
Copy link
Member

processClosureNode returned a scope with by-ref captured variable modifications already applied. In processArgs, this polluted the scope used for evaluating subsequent arguments - but closures are not called during argument evaluation, so by-ref changes cannot have taken effect yet.

The fix separates the by-ref data (closureResultScope, byRefUses) from the returned scope in ProcessClosureResult and lets callers decide when to apply it. The standalone closure call site applies immediately, while processArgs defers it until after all arguments are processed - same pattern as the existing deferral of processImmediatelyCalledCallable.

processClosureNode returned a scope with by-ref captured variable
modifications already applied. In processArgs, this polluted the
scope used for evaluating subsequent arguments - but closures are
not called during argument evaluation, so by-ref changes cannot
have taken effect yet.

The fix separates the by-ref data (closureResultScope, byRefUses)
from the returned scope in ProcessClosureResult and lets callers
decide when to apply it. The standalone closure call site applies
immediately, while processArgs defers it until after all arguments
are processed - same pattern as the existing deferral of
processImmediatelyCalledCallable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ondrejmirtes ondrejmirtes merged commit 996ad98 into 2.1.x Feb 10, 2026
633 of 637 checks passed
@ondrejmirtes ondrejmirtes deleted the by-ref-closure-scope branch February 10, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant